package com.anxin.service.impl;

import com.anxin.entity.Schedule;
import com.anxin.mapper.ScheduleMapper;
import com.anxin.service.ScheduleService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDate;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

@Service
public class ScheduleServiceImpl implements ScheduleService {
    @Autowired
    private ScheduleMapper scheduleMapper;

    @Override
    public List<Schedule> getSchedulesByDoctorId(String doctorId) {
        return scheduleMapper.selectList(new QueryWrapper<Schedule>().eq("doctor_id", doctorId));
    }

    @Override
    public List<Schedule> getSchedulesByDoctorIdAndDate(String doctorId, LocalDate date) {
        return scheduleMapper.selectList(new QueryWrapper<Schedule>().eq("doctor_id", doctorId).eq("date", date));
    }

    @Override
    public void addSchedule(Schedule schedule) {
        scheduleMapper.insert(schedule);
    }

    @Override
    public void updateSchedule(Schedule schedule) {
        scheduleMapper.updateById(schedule);
    }

    @Override
    public void deleteSchedule(String id) {
        scheduleMapper.deleteById(id);
    }
}
